<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>用ajax向服务器发送表单数据</title>
	<script type="text/javascript">

	function submitData(){
		var obj = {
			name : document.getElementById('name').value,
			sex : document.getElementById('sex').value
		};
		console.log(obj)

		var xhr = new XMLHttpRequest();
		xhr.open('post', '/', true);
		xhr.send(JSON.stringify(obj));

		xhr.onreadystatechange = function(){
		  	if (xhr.readyState==4 && xhr.status==200){
		    	document.getElementById("result").innerHTML = xhr.responseText;
		    }
		}
	}
	</script>
</head>
<body>
	public/static_index.html
	<form id="form1">
	姓名：<input type="text" name="name" id="name" value="璇"><br/>
	性别：<input type="text" name="sex" id="sex" value="F"><br/>
	<input type="button" value="提交" onclick="submitData();">
</form>
<output id="result"></output>

</body>
</html>